using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Zosnn.Models.Mapping
{
    public class UserInfoMap : EntityTypeConfiguration<UserInfo>
    {
        public UserInfoMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Address)
                .HasMaxLength(500);

            this.Property(t => t.Tel)
                .HasMaxLength(50);

            this.Property(t => t.Position)
                .HasMaxLength(200);

            // Table & Column Mappings
            this.ToTable("UserInfo");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Address).HasColumnName("Address");
            this.Property(t => t.Tel).HasColumnName("Tel");
            this.Property(t => t.Position).HasColumnName("Position");
            this.Property(t => t.Usually).HasColumnName("Usually");
            this.Property(t => t.UserID).HasColumnName("UserID");

            // Relationships
            this.HasOptional(t => t.User)
                .WithMany(t => t.UserInfoes)
                .HasForeignKey(d => d.UserID);

        }
    }
}
